import {reqAttractionList} from '@/api/index'

const state = {
    // 数据初始值
    attractionList: []
}

const mutations = {
    setAttractionList(state, attractionList){
        state.attractionList = attractionList;
    }
}

// 写到这里 可以通过 state.attraction.attractionList 识别到
const actions = {
    // 通过API里面的接口函数调用，向服务器发送请求，获取服务器的数据
    async attractionList({commit}){
        const result = await reqAttractionList();
        if(result.code==200){
            // 第一个参数 对应 mutations 中的值
            commit('setAttractionList',result.data)
            // console.log(result);
        }
    },
}

const getters = {

}

export default{
    state,
    mutations,
    actions,
    getters
}